package com.shuang.mapper;

import com.shuang.pojo.Student;
import com.shuang.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    /*条件分页查询*/
    List<Student> page(StudentQueryParam studentQueryParam);

    /*添加学员*/
    @Insert("insert into student (name, no, gender, phone, id_card, is_college, address, degree, " +
            "graduation_date, clazz_id, create_time, update_time)" +
            "values (#{name}, #{no}, #{gender}, #{phone}, #{idCard}, #{isCollege}," +
            " #{address}, #{degree}, #{graduationDate}, #{clazzId}, #{createTime}, #{updateTime})")
    void save(Student student);

    /*根据id查询学员 -> 查询回显*/
    @Select("select id, name, no, gender, phone, id_card, is_college, address, " +
                   "degree, graduation_date, clazz_id, violation_count, violation_score, " +
                   "create_time, update_time from student  where id = #{id}")
    Student getInfo(Integer id);

    /*更新学员信息*/
    void update(Student student);

    /*删除学员*/
    void delete(List<Integer> ids);

    /*违纪处理*/
    void violate(Student student);

//    统计学员学历信息
    @MapKey("name")
    List<Map<String, Object>> getStudentDegreeData();
}
